package com.example.java.other;

import java.nio.charset.Charset;

public class MyApp {

    private static void testError() {
        throw new Error(); //抛出error不用方法签名
    }

    private static void testA(){
//        int &s;
//        int !s;
//        int #s;
        int $s; //合法！
//        int %s;
//        int &s;
//        int *s;
        int _s;
//        int -s;
//        int +s;
    }

    public void test(){

    }

    public static void test1(){
        MyApp app = new MyApp();
        app.test();
    }

    private static void testThrowable() throws Throwable {
        throw new Throwable();
    }

    private static void testException() throws Exception {
        throw new Exception();
    }

    private static void test11(){
        Byte b1 = 127;
        Byte b2 = 127;
        System.out.println(b1 == b2);
        Short s1 = 127;
        Short s2 = 127;
        System.out.println(s1 == s2);
        Integer i1 = 127;
        Integer i2 = 127;
        System.out.println(i1 == i2);
        Long l1 = 127L;
        Long l2 = 127L;
        System.out.println(l1 == l2);
        Character c1 = 127;
        Character c2 = 127;
        System.out.println(c1 == c2);
        Character c3 = 128;
        Character c4 = 128;
        System.out.println(c3 == c4);
        Boolean bl1 = true;
        Boolean bl2 = true;
        System.out.println(bl1 == bl2);
        Boolean bl3 = false;
        Boolean bl4 = false;
        System.out.println(bl3 == bl4);
    }

    private static void testString(){
        String str1 = "hello";
        String str2 = "hello";
        System.out.println(str1 == str2);
        String str3 = new String("hello");
        System.out.println(str1 == str3);
        String str4 = new String(str1);
        System.out.println(str1 == str4);
    }

    private static void testChar(){
        char c = '\u0023';// \u000A
        c= 65;
//        short ci = c;//char对应转换int.
        System.out.println(c);
        System.out.println(Charset.defaultCharset());
        System.out.println(System.getProperty("file.encoding").toString());//jvm -Dfile.encoding = UTF-16 更改字符
    }

    private static void swap(String s){
        s = null;
    }

    private static void swap(Father father){ //传入的参数只是复制了一份引用 所以 // 实际上也不是引用 根本不是引用  就是一份副本
        father.setValue(100);//引用指向的值被改了。
        father = null; //所以这里只是给引用空值但是原来的引用没有被改变
    }

    private static void testParam(){
        String a = "s";
        swap(a);
        System.out.println(a);
        Father father = new Father();
        swap(father);
        System.out.println(father);
    }
}
